CachedSynchronizedDictionary

Ecng.Collections

Represents a thread-safe dictionary with cached keys, values, and key-value pairs for improved performance.

Herda de: SynchronizedDictionary<T, T>

Construtores

CachedSynchronizedDictionary
public CachedSynchronizedDictionary()
cachedSynchronizedDictionary = CachedSynchronizedDictionary()

Initializes a new instance of the CachedSynchronizedDictionary class.

CachedSynchronizedDictionary
public CachedSynchronizedDictionary(int capacity)
cachedSynchronizedDictionary = CachedSynchronizedDictionary(capacity)

Initializes a new instance of the CachedSynchronizedDictionary class with the specified initial capacity.

capacity
The initial number of elements that the dictionary can contain.
CachedSynchronizedDictionary
public CachedSynchronizedDictionary(IEqualityComparer<TKey> comparer)
cachedSynchronizedDictionary = CachedSynchronizedDictionary(comparer)

Initializes a new instance of the CachedSynchronizedDictionary class with the specified equality comparer.

comparer
The equality comparer to use when comparing keys.
CachedSynchronizedDictionary
public CachedSynchronizedDictionary(int capacity, IEqualityComparer<TKey> comparer)
cachedSynchronizedDictionary = CachedSynchronizedDictionary(capacity, comparer)

Initializes a new instance of the CachedSynchronizedDictionary class with the specified initial capacity and equality comparer.

capacity
The initial number of elements that the dictionary can contain.
comparer
The equality comparer to use when comparing keys.

Propriedades

CachedKeys
public TKey[] CachedKeys { get; }
value = cachedSynchronizedDictionary.CachedKeys

Gets an array of cached keys from the dictionary.

CachedPairs
public KeyValuePair<TKey, TValue>[] CachedPairs { get; }
value = cachedSynchronizedDictionary.CachedPairs

Gets an array of cached key-value pairs from the dictionary.

CachedValues
public TValue[] CachedValues { get; }
value = cachedSynchronizedDictionary.CachedValues

Gets an array of cached values from the dictionary.

Item
public override TValue Item { set; }
cachedSynchronizedDictionary.Item = value

Gets or sets the value associated with the specified key.

key
The key of the value to get or set.

Retorna: The value associated with the specified key.

Métodos

Add
public override void Add(TKey key, TValue value)
cachedSynchronizedDictionary.Add(key, value)

Adds the specified key and value to the dictionary.

key
The key of the element to add.
value
The value of the element to add.
Clear
public override void Clear()
cachedSynchronizedDictionary.Clear()

Removes all keys and values from the dictionary.

OnResetCache
protected virtual void OnResetCache(bool isKey)
cachedSynchronizedDictionary.OnResetCache(isKey)

Resets the cached keys, values, and key-value pairs when the dictionary is modified.

isKey
Indicates whether the cache reset is due to a key modification.
Remove
public override bool Remove(TKey key)
result = cachedSynchronizedDictionary.Remove(key)

Removes the value with the specified key from the dictionary.

key
The key of the element to remove.

Retorna: true if the element is successfully found and removed; otherwise, false.